//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Resource Application Block
//===============================================================================

using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity;
using EntLibContrib.Resource.Configuration.Unity;
using EntLibContrib.Resource.Providers;

namespace EntLibContrib.Resource.Configuration
{
	/// <summary>
	/// Configuration information for DataResourceProviderData. This class represents the extra information, over and
	/// above what is defined in <see cref="ResourceProviderData" />, needed to connect resource to the Data block.
	/// </summary>
	[Assembler(typeof(DataResourceProviderAssembler))]
	[ContainerPolicyCreator(typeof(DataResourceProviderPolicyCreator))]
	public class DataResourceProviderData : ResourceProviderData
	{
		#region Constants
		private const string databaseInstanceNameProperty = "databaseInstanceName";
		#endregion

		#region Properties
		/// <summary>
		/// Name of the database instance to use for resources. Instance must be defined in Data configuration.
		/// </summary>
		[ConfigurationProperty(databaseInstanceNameProperty, IsRequired = true)]
		public string DatabaseInstanceName
		{
			get { return (string)base[databaseInstanceNameProperty]; }
			set { base[databaseInstanceNameProperty] = value; }
		}
		#endregion

		#region Construction
		/// <overloads>
		/// Initializes an instance of a <see cref="DataResourceProviderData"/> class.
		/// </overloads>
		/// <summary>
		/// Initializes a new instance of the <see cref="DataResourceProviderData"/> class.
		/// </summary>
		public DataResourceProviderData()
		{
		}

		/// <summary>
		/// Initialize a new instance of the <see cref="DataResourceProviderData"/> class.
		/// </summary>
		/// <param name="name">The name of the <see cref="DataResourceProviderData"/>.</param>
		/// <param name="databaseInstanceName">Name of the database instance to use for resources. Instance must be defined in Data configuration.</param>
		/// <param name="resourceBaseName">Name of the resource base.</param>
		public DataResourceProviderData(string name, string databaseInstanceName, string resourceBaseName)
			: base(name, typeof(DataResourceProvider), resourceBaseName)
		{
			this.DatabaseInstanceName = databaseInstanceName;
		}
		#endregion
	}
}